function User(data) {
    this.avatar = data.avatarUrl;
    this.name = data.nickname || data.nickName;
    this.openid = data.openid || data.openId;
    var img = wx.createImage();
    img.src = this.avatar;
    this.img = img;
}

User.prototype.getNameLength = function(length) {
    let name = this.name;
    for(let i = 0,c = 0; i < name.length; i++) {
        if(name.charCodeAt(i) < 200) {
            c++;
        } else {
            c+=2;
        }
        if(c >= (length + 1) * 2 && i < name.length) {
            name = name.slice(0,i) + "...";
            break;
        }
    }
    return name;
}

exports.User = User;
